home *** CD-ROM | disk | FTP | other *** search
/ Shareworld 8 / Shareworld 8 (Disk 2 of 2).adf / Programs / MachineCodeHelloWorld / HelloWorld.KW3 (.txt) < prev    next >
Encoding:
WordWorth  |  1997-03-06  |  8.1 KB  |  224 lines

  1. ;  -------------------------------------------------------------------
  2. ;  A Hello World program based on the Blitz Basic original
  3. ;  by Carl Read. Assembler version by Matthew Goode 18/1/97
  4. ;
  5. ;  Feel free to use any part of this program in your own, and, although
  6. ;  you can claim it as your own, please be considerate and give credit
  7. ;  where credit is due.
  8. ;  -------------------------------------------------------------------
  9.  
  10. ;  -------------------------------------------------------------------
  11. ;  ------------------- Environment Design ----------------------------
  12.  
  13. UseIntuitionLib =   1
  14. UseGraphicsLib  =   1
  15.  
  16. ;  -------------------------------------------------------------------
  17. ;  ------------------ Included (External) Constants ------------------
  18.  
  19.     IncDir "work:Assem/Include/"
  20.  
  21. ;  ----- Executive Stuff ------
  22.     Include "exec/Exec_lib.i"
  23.     Include "exec/ExecBase.i"
  24.  
  25. ;  ----- Graphics Stuff ------
  26.     Include "Graphics/Graphics_lib.i"
  27.  
  28. ;  ----- Intuition Stuff ------
  29.     Include "Intuition/Intuition_lib.i"
  30.     Include "Intuition/Intuition.i"
  31.  
  32. ;  ----- WorkBench Stuff ------
  33.     Include "WorkBench/WorkBench.i"
  34.  
  35. ;  ----- Other Stuff ------
  36.     Include "Libraries/DosExtens.i"
  37.  
  38. ;  ----- My Stuff ------
  39.     IncDir "work:Assem/MyIncludes/"
  40.     Include "StandardMacros.i"
  41.     Include "SimpleWorkbenchStart.i"
  42.     Include "OpIntuitionMacros.i"
  43.  
  44. ;  -------------------------------------------------------------------
  45. ;  ------------------- Internal Constants ----------------------------
  46.  
  47. screenWidth =   640
  48. screenHeight    =   256
  49. mainWindowWidth =   300
  50. mainWindowHeight    =   200
  51. mainWindowXPos  =   (screenWidth-mainWindowWidth)/2
  52. mainWindowYPos  =   (screenHeight-mainWindowHeight)/2
  53. mainWindowDetailPen =   2
  54. mainWindowBlockPen  =   1
  55. mainWindowIDCMP =   CLOSEWINDOW
  56. mainWindowFlags =   
  57. WINDOWSIZING+WINDOWDRAG+WINDOWDEPTH+WINDOWCLOSE+SMART_REFRESH+RMBTRAP+GIMMEZEROZERO
  58. mainWindowMinWidth  =   40
  59. mainWindowMinHeight =   40
  60. mainWindowMaxWidth  =   -1
  61. mainWindowMaxHeight =   -1
  62.  
  63. mainWindowType  =   WBENCHSCREEN
  64.  
  65. textCol =   1
  66. backCol =   0
  67.  
  68. ;  -------------------------------------------------------------------
  69. ;  --------------------- Internal Macros -----------------------------
  70.  
  71. ;  -------------------------------------------------------------------
  72. ;  -------------------- Main Program ---------------------------------
  73.  
  74. TheBegining
  75.     StartHerUp
  76. OpenWindows
  77.     Bsr OpenMainWindow
  78.     beq WindowFailure
  79.  
  80.     Bsr MainSetup
  81.     Bsr MainLoop
  82.  
  83. WindowFailure
  84.     Bsr CloseMainWindow
  85.  
  86.     TidyUp  ;No need for a RTS
  87.  
  88.  
  89. ;  -------------------------------------------------------------------
  90.  
  91. MainSetup
  92.     Move.w #0,scrollCount
  93.     rts
  94.  
  95. MainLoop
  96. .ll1
  97.     ;CALLGRAF WaitTOF   ;Use this line for a smoother demo.
  98.  
  99.     move.l mainWindowHandle,a2
  100.     move.l mainWindowRast,a3
  101.  
  102.     moveq #0,d2     ;Here we get the dimensions of the window
  103.     moveq #0,d3     ;Note that since this is a GIMMEZEROZERO
  104.                     ;Window we do not have to worry about the
  105.                     ;borders. Usually it is better to use
  106.                     ;Normal Windows as they can be faster.
  107.     move.w wd_GZZWidth(a2),d4
  108.     move.w wd_GZZHeight(a2),d5
  109.     Sub.w #1,d4 ;Adjust for 'Of by One Errors
  110.     Sub.w #1,d5
  111.  
  112.     tst.w scrollCount       ;Is it time to Reprint?
  113.     bne .noReprintMessage
  114.     GetFontHeight a3,d0     ;Get verticle displacement
  115.     move.w d0,scrollCount
  116.  
  117.     move.w d5,d1
  118.     sub.w d0,d1     ;Get YPos of text
  119.  
  120.     move.w d2,d0    ;Get XPos of text
  121.  
  122.     lea iTextStruct,a1
  123.     lea message,a0
  124.     move.l a0,textToPrint_p
  125.     lea (a3),a0 ;Get RastPort
  126.     CALLINT PrintIText
  127.  
  128. .noReprintMessage
  129.     moveq #0,d0     ;No horizontal scroll
  130.     moveq #1,d1
  131.     lea (a3),a1     ;Get RastPort for scroll
  132.     CALLGRAF ScrollRaster
  133.  
  134.     sub.w #1,scrollCount
  135.  
  136.  
  137.     move.l mainWindowHandle,a3
  138.     Bsr GetMessageFromWindow
  139.     Beq .ll1
  140.     Cmp.l #CLOSEWINDOW,d1   ;Not really necessary as this is the only
  141.                 ;message possible
  142.     bne .ll1
  143.     rts
  144.  
  145. ;  -------------------------------------------------------------------
  146.  
  147. GetMessageFromWindow
  148.     ;Waits for a message from the window in a3 and then procedes to
  149.     ;get message.
  150.     ;On Exiting: a0 - holds pointer to message
  151.     ;            d1 - holds message class
  152.     ;            z flag set if message Found
  153.     move.l wd_UserPort(a3),a0
  154.     CALLEXEC GetMsg
  155.     move.l d0,a0
  156.     move.l im_Class(a0),d1
  157.     Tst.l d0
  158.     rts
  159.  
  160. ;  -------------------------------------------------------------------
  161.  
  162. OpenMainWindow
  163.     ;Opens the main window
  164.     ; D0 holds handle on exit (will be zero if failure)
  165.     ; No need to test as Status Flags will already be set
  166.     Lea newMainWindow,a0
  167.     CALLINT OpenWindow
  168.     Move.l d0,a0
  169.     Move.l wd_RPort(a0),mainWindowRast
  170.     Move.l d0,mainWindowHandle
  171.     rts
  172.  
  173. CloseMainWindow
  174.     ;Closes the Window if it was opened
  175.     Move.l mainWindowHandle,d0
  176.     Beq .noWindow
  177.     Move.l d0,a0
  178.     CALLINT CloseWindow
  179.     Clr.l mainWindowHandle
  180. .noWindow
  181.     rts
  182.  
  183.  
  184. ;  -------------------------------------------------------------------
  185. ;  ---------------- Physical Constants -------------------------------
  186.  
  187.     Include "LibraryNames.i"
  188.     even
  189.  
  190. newMainWindow
  191.     dc.w mainWindowXPos,mainWindowYPos,mainWindowWidth,mainWindowHeight
  192.     dc.b mainWindowDetailPen,mainWindowBlockPen
  193.     dc.l mainWindowIDCMP,mainWindowFlags
  194.     dc.l 0  ;Pointer to first Gadget
  195.     dc.l 0,mainWindowTitle,0,0  ;CheckMark,title,screen,bitmap
  196.     dc.w 
  197. mainWindowMinWidth,mainWindowMinWidth,mainWindowMaxWidth,mainWindowMaxHeight
  198.     dc.w 1  ;mainWindowType
  199.  
  200. mainWindowTitle
  201.     dc.b "<- Click to exit",0
  202.     Even
  203.  
  204. message
  205.     dc.b " Hello World!  I'm an ASSEMBLER program!!!!!!!.",0
  206.  
  207. ;  -------------------------------------------------------------------
  208. ;  ---------------- Variables ----------------------------------------
  209.  
  210. iTextStruct dc.b textCol,backCol,RP_JAM2,0
  211.         dc.w 0,0
  212.         dc.l 0
  213. textToPrint_p   dc.l 0,0
  214.  
  215.     Include "StandardVaribles.i"
  216.  
  217. mainWindowHandle    ds.l 1
  218. mainWindowRast      ds.l 1
  219.  
  220. scrollCount ds.w 1  ;The scroller counter
  221.  
  222. ;  -------------------------------------------------------------------
  223.  
  224.